<template>
    <div style="padding: 15px">
        <el-table
            v-loading="loading"
            :header-cell-style="headerCellStyle"
            :data="tableData"
            size="small"
            max-height="350px"
        >
            <el-table-column label="商家编号" prop="companyCode">
            </el-table-column>
            <el-table-column
                label="商家名称"
                prop="companyName"
            ></el-table-column>
            <el-table-column
                label="设备类型"
                prop="terminalTypeName"
            ></el-table-column>
            <el-table-column
                label="升级包文件类型"
                prop="upgradePackageFileTypeName"
            ></el-table-column>
            <el-table-column
                label="指定版本号"
                prop="inSpecifiedVersionCode"
            ></el-table-column>
            <el-table-column
                label="创建时间"
                prop="createTime"
            ></el-table-column>
            <el-table-column
                label="更新时间"
                prop="updateTime"
            ></el-table-column>
        </el-table>
        <div style="width: 100%; padding: 15px" class="right">
            <el-pagination
                background
                :current-page.sync="currentPage"
                @current-change="handleCurrentChange"
                :page-size="pageSize"
                layout="prev, pager, next, total"
                :total="totalNum"
            ></el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        value: Boolean,
        currRow: Object
    },
    data () {
        return {
            currentPage: 1,
            pageSize: 10,
            totalNum: 0,
            loading: false,
            tableData: [],
            showValue: false,
            terminalTypeList: [],
            packageFileTypeList: [],
            form: {
                terminalType: '',
                upgradePackageFileType: ''
            }
        }
    },
    watch: {
    },
    created () {
        this.getList()
    },
    methods: {
        search () {
            this.currentPage = 1
            this.getList()
        },
        handleCurrentChange (page) {
            // 换页
            this.currentPage = page
            this.getList()
        },
        // 获取列表
        async getList () {
            this.loading = true
            const res = await this.$http.post(this.$store.state.IP + '/upgradeManage/upgradeTaskList', {
                companyCode: this.currRow.companyCode,
                page: this.currentPage - 1,
                size: 10
            })
            let response = res.data
            if (response.ret === '0') {
                this.loading = false
                this.tableData = response.res.list
                this.totalNum = response.res.total
            } else {
                this.loading = false
            }
        },
        // 清空数据
        clearData () {
            this.currentPage = 1
            this.showValue = false
            this.tableData = []
        }
    }
}
</script>
<style lang="stylus" rel="stylesheet/stylus" scoped>
.item
    width: 110px

.right
    text-align: right
</style>